<?php
/**
 * Filtering On Agency List
 */
use Doctrine\DBAL\Connection;
use Fox\Html\DropList\CheckBox;
use Fox\Common\Customer;
use Fox\Generator;

$finder = new Customer();
$agFragments[] = new Fox\Dao\SqlFragment("type = ?",array(Fox\Common\Customer::TYPE_OFFICE));
if(!Fox\Authorization\Manager::check(User::AUTH_VIEW_ALL))
{
	$agFragments[] = new Fox\Dao\SqlFragment("customerid IN (?)",
											array(User::current()->agency()),
											array(Connection::PARAM_STR_ARRAY));
}
$agencies = $finder->find(Fox\Dao\SqlFragment::combine($agFragments),array("name1" => false));
$input = new CheckBox("op_entity",null,null,null,null,null,Fox\Html\DropList\CheckBox::RMODE_VERTICAL);
$input->nbOfItemByBlock(3)
	  ->options($agencies,
			    Generator::useAttribute('customerid'),
			    Generator::useAttribute('name1'));
return $input;